package top.sky.log;

import top.sky.log.impl.LoggerWrapper;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;

/**
 * 自定义LoggerFactory 包装{@link org.slf4j.LoggerFactory}类并替换之。
 * 包装的目的是为了加入动态打印日志，方便调试的时候日志的输出。
 *
 * @author shijin.liu
 * @since 2023-07-01
 */
public final class LoggerFactory {

    /**
     * Return a logger named corresponding to the class passed as parameter,
     * using the statically bound {@link ILoggerFactory} instance.
     *
     * <p>
     * In case the the <code>clazz</code> parameter differs from the name of the
     * caller as computed internally by SLF4J, a logger name mismatch warning
     * will be printed but only if the
     * <code>slf4j.detectLoggerNameMismatch</code> system property is set to
     * true. By default, this property is not set and no warnings will be
     * printed even in case of a logger name mismatch.
     *
     * @param clazz The returned logger will be named after clazz.
     * @return The logger.
     * @see <a href="http://www.slf4j.org/codes.html#loggerNameMismatch">Detected logger name mismatch</a>
     */
    public static Logger getLogger(Class<?> clazz) {
        return new LoggerWrapper(org.slf4j.LoggerFactory.getLogger(clazz));
    }
}
